package com.clstu.staticmathod_.codeblock_;

public class CodeBlock {
    public static void main(String[] args) {
        new Movie("你好，世界");
        new Movie("星际穿越",10);
    }
}
class Movie{
    private String name;
    private double price;
    private String actor;
    static {
        System.out.println("===============================");//代码块，在构造器之前执行，无论哪个构造器都会执行，每构造一个队像都会执行一次
        System.out.println("屏幕打开。。。。");           //静态代码块只执行一次，构造第一个对象的时候执行，后面不会再执行

        System.out.println("看会广告。。。。。");
        System.out.println("电影开始。。。。。。。！");
    }

    public Movie(String name) {
        this.name = name;
    }

    public Movie(String name, double price) {
        this.name = name;
        this.price = price;
    }

    public Movie(String name, double price, String actor) {
        this.name = name;
        this.price = price;
        this.actor = actor;
    }
}